package com.simon.train.business.controller.admin;


import com.simon.train.business.dto.TrainSeatQueryDto;
import com.simon.train.business.dto.TrainSeatSaveDto;
import com.simon.train.business.service.TrainSeatService;
import com.simon.train.business.vo.TrainSeatQueryVO;
import com.simon.train.common.Result.Result;
import com.simon.train.common.vo.PageVO;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/trainSeat")
public class TrainSeatAdminController {

    @Resource
    private TrainSeatService trainSeatService;

    @PostMapping("/save")
    public Result<Object> SaveTrainSeat(@Valid @RequestBody TrainSeatSaveDto trainSeatSaveDto){
        trainSeatService.SaveTrainSeat(trainSeatSaveDto);
        return new Result<>();
    }

    @GetMapping("/queryList")
    public Result<PageVO<TrainSeatQueryVO>> TrainSeatQueryList(@Valid TrainSeatQueryDto trainSeatQueryDto){
         /**
         * businessId通过线程变量获取 从而不需要由前端传入 保证了效率和安全性
         */
        PageVO<TrainSeatQueryVO> lists = trainSeatService.QueryTrainSeatList(trainSeatQueryDto);
        return new Result<>(lists);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Object> DeleteTrainSeat(@PathVariable("id") Long id){
        trainSeatService.deleteTrainSeat(id);
        return new Result<>();
    }

}
